home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93c.txt
/
000010_icon-group-sender _Mon Jul 12 15:57:36 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-02-02
|
2KB
Received: by cheltenham.cs.arizona.edu; Mon, 12 Jul 1993 14:07:01 MST
Date: Mon, 12 Jul 93 15:57:36 CDT
From: "Richard L. Goerwitz" <goer@midway.uchicago.edu>
Message-Id: <9307122057.AA02178@midway.uchicago.edu>
To: icon-group@cs.arizona.edu
Subject: sortff
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
I've received several requests for this, so here goes.
It's fairly new, and I haven't tested it in a broad
range of contexts, so please feel free to post bug fixes
or useful modifications....
-Richard
############################################################################
#
# Name: sortff.icn
#
# Title: sortf with multiple field arguments
#
# Author: Richard L. Goerwitz
#
# Version: 1.1
#
############################################################################
#
# Sortff is like sortf(), except takes an unlimited number of field
# arguments. E.g. if you want to sort a list of structures on field
# 5, and (for those objects that have the same field 5) do a sub-sort
# on field 2, you would use "sortff(list_of_objects, 5, 2)."
#
############################################################################
procedure sortff(arglst[])
local sortfield, i, old_i
*arglst[1] <= 1 | *arglst = 1 & { return arglst[1] }
sortfield := arglst[2] | { return sortf(arglst[1]) }
arglst[1] := sortf(arglst[1], sortfield)
old_i := 1
every i := old_i+1 to *arglst[1] do {
if not (arglst[1][old_i][sortfield] === arglst[1][i][sortfield])
then {
return sortff!(push(arglst[3:0], arglst[1][old_i : i])) |||
sortff!(push(arglst[2:0], arglst[1][i : 0]))
}
}
return sortff!(push(arglst[3:0], arglst[1]))
end